home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 March / PCWMAR09.iso / Software / Freeware / Adobe Media Player 1.6 / adobe_media_player.air / AMP.swf / scripts / mx / managers / FocusManager.as < prev    next >
Encoding:
Text File  |  2008-11-25  |  50.6 KB  |  1,502 lines

  1. package mx.managers
  2. {
  3.    import flash.display.DisplayObject;
  4.    import flash.display.DisplayObjectContainer;
  5.    import flash.display.InteractiveObject;
  6.    import flash.display.Sprite;
  7.    import flash.events.Event;
  8.    import flash.events.FocusEvent;
  9.    import flash.events.IEventDispatcher;
  10.    import flash.events.KeyboardEvent;
  11.    import flash.events.MouseEvent;
  12.    import flash.system.Capabilities;
  13.    import flash.text.TextField;
  14.    import flash.ui.Keyboard;
  15.    import mx.core.FlexSprite;
  16.    import mx.core.IButton;
  17.    import mx.core.IChildList;
  18.    import mx.core.IRawChildrenContainer;
  19.    import mx.core.ISWFBridgeProvider;
  20.    import mx.core.ISWFLoader;
  21.    import mx.core.IUIComponent;
  22.    import mx.core.SWFBridgeGroup;
  23.    import mx.core.mx_internal;
  24.    import mx.events.FlexEvent;
  25.    import mx.events.FocusRequestDirection;
  26.    import mx.events.SWFBridgeEvent;
  27.    import mx.events.SWFBridgeRequest;
  28.    
  29.    use namespace mx_internal;
  30.    
  31.    public class FocusManager implements IFocusManager
  32.    {
  33.       mx_internal static const VERSION:String = "3.2.0.3958";
  34.       
  35.       private static const FROM_INDEX_UNSPECIFIED:int = -2;
  36.       
  37.       private var lastActiveFocusManager:FocusManager;
  38.       
  39.       private var _showFocusIndicator:Boolean = false;
  40.       
  41.       private var focusableCandidates:Array;
  42.       
  43.       private var LARGE_TAB_INDEX:int = 99999;
  44.       
  45.       private var browserFocusComponent:InteractiveObject;
  46.       
  47.       private var calculateCandidates:Boolean = true;
  48.       
  49.       private var _lastFocus:IFocusManagerComponent;
  50.       
  51.       private var lastAction:String;
  52.       
  53.       private var focusSetLocally:Boolean;
  54.       
  55.       private var focusableObjects:Array;
  56.       
  57.       private var swfBridgeGroup:SWFBridgeGroup;
  58.       
  59.       private var defButton:IButton;
  60.       
  61.       private var _form:IFocusManagerContainer;
  62.       
  63.       private var popup:Boolean;
  64.       
  65.       private var focusChanged:Boolean;
  66.       
  67.       private var _defaultButtonEnabled:Boolean = true;
  68.       
  69.       private var activated:Boolean = false;
  70.       
  71.       private var _defaultButton:IButton;
  72.       
  73.       private var fauxFocus:DisplayObject;
  74.       
  75.       private var _focusPane:Sprite;
  76.       
  77.       private var skipBridge:IEventDispatcher;
  78.       
  79.       public var browserMode:Boolean;
  80.       
  81.       public function FocusManager(param1:IFocusManagerContainer, param2:Boolean = false)
  82.       {
  83.          var sm:ISystemManager = null;
  84.          var bridge:IEventDispatcher = null;
  85.          var container:IFocusManagerContainer = param1;
  86.          var popup:Boolean = param2;
  87.          super();
  88.          this.popup = popup;
  89.          browserMode = Capabilities.playerType == "ActiveX" && !popup;
  90.          container.focusManager = this;
  91.          _form = container;
  92.          focusableObjects = [];
  93.          focusPane = new FlexSprite();
  94.          focusPane.name = "focusPane";
  95.          addFocusables(DisplayObject(container));
  96.          container.addEventListener(Event.ADDED,addedHandler);
  97.          container.addEventListener(Event.REMOVED,removedHandler);
  98.          container.addEventListener(FlexEvent.SHOW,showHandler);
  99.          container.addEventListener(FlexEvent.HIDE,hideHandler);
  100.          if(container.systemManager is SystemManager)
  101.          {
  102.             if(container != SystemManager(container.systemManager).application)
  103.             {
  104.                container.addEventListener(FlexEvent.CREATION_COMPLETE,creationCompleteHandler);
  105.             }
  106.          }
  107.          try
  108.          {
  109.             container.systemManager.addFocusManager(container);
  110.             sm = mx_internal::form.systemManager;
  111.             swfBridgeGroup = new SWFBridgeGroup(sm);
  112.             if(!popup)
  113.             {
  114.                swfBridgeGroup.parentBridge = sm.swfBridgeGroup.parentBridge;
  115.             }
  116.             if(sm.useSWFBridge())
  117.             {
  118.                sm.addEventListener(SWFBridgeEvent.BRIDGE_APPLICATION_UNLOADING,removeFromParentBridge);
  119.                bridge = swfBridgeGroup.parentBridge;
  120.                if(bridge)
  121.                {
  122.                   bridge.addEventListener(SWFBridgeRequest.MOVE_FOCUS_REQUEST,focusRequestMoveHandler);
  123.                   bridge.addEventListener(SWFBridgeRequest.SET_SHOW_FOCUS_INDICATOR_REQUEST,setShowFocusIndicatorRequestHandler);
  124.                }
  125.                if(Boolean(bridge) && !(mx_internal::form.systemManager is SystemManagerProxy))
  126.                {
  127.                   bridge.addEventListener(SWFBridgeRequest.ACTIVATE_FOCUS_REQUEST,focusRequestActivateHandler);
  128.                   bridge.addEventListener(SWFBridgeRequest.DEACTIVATE_FOCUS_REQUEST,focusRequestDeactivateHandler);
  129.                   bridge.addEventListener(SWFBridgeEvent.BRIDGE_FOCUS_MANAGER_ACTIVATE,bridgeEventActivateHandler);
  130.                }
  131.                container.addEventListener(Event.ADDED_TO_STAGE,addedToStageHandler);
  132.             }
  133.          }
  134.          catch(e:Error)
  135.          {
  136.          }
  137.       }
  138.       
  139.       private function dispatchSetShowFocusIndicatorRequest(param1:Boolean, param2:IEventDispatcher) : void
  140.       {
  141.          var _loc3_:SWFBridgeRequest = new SWFBridgeRequest(SWFBridgeRequest.SET_SHOW_FOCUS_INDICATOR_REQUEST,false,false,null,param1);
  142.          dispatchEventFromSWFBridges(_loc3_,param2);
  143.       }
  144.       
  145.       private function creationCompleteHandler(param1:FlexEvent) : void
  146.       {
  147.          if(DisplayObject(mx_internal::form).visible && !activated)
  148.          {
  149.             mx_internal::form.systemManager.activate(mx_internal::form);
  150.          }
  151.       }
  152.       
  153.       private function addFocusables(param1:DisplayObject, param2:Boolean = false) : void
  154.       {
  155.          var addToFocusables:Boolean = false;
  156.          var focusable:IFocusManagerComponent = null;
  157.          var doc:DisplayObjectContainer = null;
  158.          var rawChildren:IChildList = null;
  159.          var i:int = 0;
  160.          var o:DisplayObject = param1;
  161.          var skipTopLevel:Boolean = param2;
  162.          if(o is IFocusManagerComponent && !skipTopLevel)
  163.          {
  164.             addToFocusables = false;
  165.             if(o is IFocusManagerComponent)
  166.             {
  167.                focusable = IFocusManagerComponent(o);
  168.                if(focusable.focusEnabled)
  169.                {
  170.                   if(Boolean(focusable.tabEnabled) && isTabVisible(o))
  171.                   {
  172.                      addToFocusables = true;
  173.                   }
  174.                }
  175.             }
  176.             if(addToFocusables)
  177.             {
  178.                if(focusableObjects.indexOf(o) == -1)
  179.                {
  180.                   focusableObjects.push(o);
  181.                   calculateCandidates = true;
  182.                }
  183.                o.addEventListener("tabEnabledChange",tabEnabledChangeHandler);
  184.                o.addEventListener("tabIndexChange",tabIndexChangeHandler);
  185.             }
  186.          }
  187.          if(o is DisplayObjectContainer)
  188.          {
  189.             doc = DisplayObjectContainer(o);
  190.             o.addEventListener("tabChildrenChange",tabChildrenChangeHandler);
  191.             if(doc.tabChildren)
  192.             {
  193.                if(o is IRawChildrenContainer)
  194.                {
  195.                   rawChildren = IRawChildrenContainer(o).rawChildren;
  196.                   i = 0;
  197.                   while(i < rawChildren.numChildren)
  198.                   {
  199.                      try
  200.                      {
  201.                         addFocusables(rawChildren.getChildAt(i));
  202.                      }
  203.                      catch(error:SecurityError)
  204.                      {
  205.                      }
  206.                      i++;
  207.                   }
  208.                }
  209.                else
  210.                {
  211.                   i = 0;
  212.                   while(i < doc.numChildren)
  213.                   {
  214.                      try
  215.                      {
  216.                         addFocusables(doc.getChildAt(i));
  217.                      }
  218.                      catch(error:SecurityError)
  219.                      {
  220.                      }
  221.                      i++;
  222.                   }
  223.                }
  224.             }
  225.          }
  226.       }
  227.       
  228.       private function tabEnabledChangeHandler(param1:Event) : void
  229.       {
  230.          calculateCandidates = true;
  231.          var _loc2_:InteractiveObject = InteractiveObject(param1.target);
  232.          var _loc3_:int = int(focusableObjects.length);
  233.          var _loc4_:int = 0;
  234.          while(_loc4_ < _loc3_)
  235.          {
  236.             if(focusableObjects[_loc4_] == _loc2_)
  237.             {
  238.                break;
  239.             }
  240.             _loc4_++;
  241.          }
  242.          if(_loc2_.tabEnabled)
  243.          {
  244.             if(_loc4_ == _loc3_ && isTabVisible(_loc2_))
  245.             {
  246.                if(focusableObjects.indexOf(_loc2_) == -1)
  247.                {
  248.                   focusableObjects.push(_loc2_);
  249.                }
  250.             }
  251.          }
  252.          else if(_loc4_ < _loc3_)
  253.          {
  254.             focusableObjects.splice(_loc4_,1);
  255.          }
  256.       }
  257.       
  258.       private function mouseFocusChangeHandler(param1:FocusEvent) : void
  259.       {
  260.          var _loc2_:TextField = null;
  261.          if(param1.relatedObject == null && "isRelatedObjectInaccessible" in param1 && param1["isRelatedObjectInaccessible"] == true)
  262.          {
  263.             return;
  264.          }
  265.          if(param1.relatedObject is TextField)
  266.          {
  267.             _loc2_ = param1.relatedObject as TextField;
  268.             if(_loc2_.type == "input" || _loc2_.selectable)
  269.             {
  270.                return;
  271.             }
  272.          }
  273.          param1.preventDefault();
  274.       }
  275.       
  276.       public function addSWFBridge(param1:IEventDispatcher, param2:DisplayObject) : void
  277.       {
  278.          if(!param2)
  279.          {
  280.             return;
  281.          }
  282.          var _loc3_:ISystemManager = _form.systemManager;
  283.          if(focusableObjects.indexOf(param2) == -1)
  284.          {
  285.             focusableObjects.push(param2);
  286.             calculateCandidates = true;
  287.          }
  288.          swfBridgeGroup.addChildBridge(param1,ISWFBridgeProvider(param2));
  289.          param1.addEventListener(SWFBridgeRequest.MOVE_FOCUS_REQUEST,focusRequestMoveHandler);
  290.          param1.addEventListener(SWFBridgeRequest.SET_SHOW_FOCUS_INDICATOR_REQUEST,setShowFocusIndicatorRequestHandler);
  291.          param1.addEventListener(SWFBridgeEvent.BRIDGE_FOCUS_MANAGER_ACTIVATE,bridgeEventActivateHandler);
  292.       }
  293.       
  294.       private function getChildIndex(param1:DisplayObjectContainer, param2:DisplayObject) : int
  295.       {
  296.          var parent:DisplayObjectContainer = param1;
  297.          var child:DisplayObject = param2;
  298.          try
  299.          {
  300.             return parent.getChildIndex(child);
  301.          }
  302.          catch(e:Error)
  303.          {
  304.             if(parent is IRawChildrenContainer)
  305.             {
  306.                return IRawChildrenContainer(parent).rawChildren.getChildIndex(child);
  307.             }
  308.             throw e;
  309.          }
  310.       }
  311.       
  312.       private function bridgeEventActivateHandler(param1:Event) : void
  313.       {
  314.          if(param1 is SWFBridgeEvent)
  315.          {
  316.             return;
  317.          }
  318.          lastActiveFocusManager = null;
  319.          _lastFocus = null;
  320.          dispatchActivatedFocusManagerEvent(IEventDispatcher(param1.target));
  321.       }
  322.       
  323.       private function focusOutHandler(param1:FocusEvent) : void
  324.       {
  325.          var _loc2_:InteractiveObject = InteractiveObject(param1.target);
  326.       }
  327.       
  328.       private function isValidFocusCandidate(param1:DisplayObject, param2:String) : Boolean
  329.       {
  330.          var _loc3_:IFocusManagerGroup = null;
  331.          if(!isEnabledAndVisible(param1))
  332.          {
  333.             return false;
  334.          }
  335.          if(param1 is IFocusManagerGroup)
  336.          {
  337.             _loc3_ = IFocusManagerGroup(param1);
  338.             if(param2 == _loc3_.groupName)
  339.             {
  340.                return false;
  341.             }
  342.          }
  343.          return true;
  344.       }
  345.       
  346.       private function removeFocusables(param1:DisplayObject, param2:Boolean) : void
  347.       {
  348.          var _loc3_:int = 0;
  349.          if(param1 is DisplayObjectContainer)
  350.          {
  351.             if(!param2)
  352.             {
  353.                param1.removeEventListener("tabChildrenChange",tabChildrenChangeHandler);
  354.             }
  355.             _loc3_ = 0;
  356.             while(_loc3_ < focusableObjects.length)
  357.             {
  358.                if(isParent(DisplayObjectContainer(param1),focusableObjects[_loc3_]))
  359.                {
  360.                   if(focusableObjects[_loc3_] == _lastFocus)
  361.                   {
  362.                      _lastFocus.drawFocus(false);
  363.                      _lastFocus = null;
  364.                   }
  365.                   focusableObjects[_loc3_].removeEventListener("tabEnabledChange",tabEnabledChangeHandler);
  366.                   focusableObjects[_loc3_].removeEventListener("tabIndexChange",tabIndexChangeHandler);
  367.                   focusableObjects.splice(_loc3_,1);
  368.                   _loc3_--;
  369.                   calculateCandidates = true;
  370.                }
  371.                _loc3_++;
  372.             }
  373.          }
  374.       }
  375.       
  376.       private function addedHandler(param1:Event) : void
  377.       {
  378.          var _loc2_:DisplayObject = DisplayObject(param1.target);
  379.          if(_loc2_.stage)
  380.          {
  381.             addFocusables(DisplayObject(param1.target));
  382.          }
  383.       }
  384.       
  385.       private function tabChildrenChangeHandler(param1:Event) : void
  386.       {
  387.          if(param1.target != param1.currentTarget)
  388.          {
  389.             return;
  390.          }
  391.          calculateCandidates = true;
  392.          var _loc2_:DisplayObjectContainer = DisplayObjectContainer(param1.target);
  393.          if(_loc2_.tabChildren)
  394.          {
  395.             addFocusables(_loc2_,true);
  396.          }
  397.          else
  398.          {
  399.             removeFocusables(_loc2_,true);
  400.          }
  401.       }
  402.       
  403.       private function sortByDepth(param1:DisplayObject, param2:DisplayObject) : Number
  404.       {
  405.          var _loc5_:int = 0;
  406.          var _loc6_:String = null;
  407.          var _loc7_:String = null;
  408.          var _loc3_:String = "";
  409.          var _loc4_:String = "";
  410.          var _loc8_:String = "0000";
  411.          var _loc9_:DisplayObject = DisplayObject(param1);
  412.          var _loc10_:DisplayObject = DisplayObject(param2);
  413.          while(_loc9_ != DisplayObject(mx_internal::form) && Boolean(_loc9_.parent))
  414.          {
  415.             _loc5_ = getChildIndex(_loc9_.parent,_loc9_);
  416.             _loc6_ = _loc5_.toString(16);
  417.             if(_loc6_.length < 4)
  418.             {
  419.                _loc7_ = _loc8_.substring(0,4 - _loc6_.length) + _loc6_;
  420.             }
  421.             _loc3_ = _loc7_ + _loc3_;
  422.             _loc9_ = _loc9_.parent;
  423.          }
  424.          while(_loc10_ != DisplayObject(mx_internal::form) && Boolean(_loc10_.parent))
  425.          {
  426.             _loc5_ = getChildIndex(_loc10_.parent,_loc10_);
  427.             _loc6_ = _loc5_.toString(16);
  428.             if(_loc6_.length < 4)
  429.             {
  430.                _loc7_ = _loc8_.substring(0,4 - _loc6_.length) + _loc6_;
  431.             }
  432.             _loc4_ = _loc7_ + _loc4_;
  433.             _loc10_ = _loc10_.parent;
  434.          }
  435.          return _loc3_ > _loc4_ ? 1 : (_loc3_ < _loc4_ ? -1 : 0);
  436.       }
  437.       
  438.       mx_internal function sendDefaultButtonEvent() : void
  439.       {
  440.          defButton.dispatchEvent(new MouseEvent("click"));
  441.       }
  442.       
  443.       public function getFocus() : IFocusManagerComponent
  444.       {
  445.          var _loc1_:InteractiveObject = mx_internal::form.systemManager.stage.focus;
  446.          return findFocusManagerComponent(_loc1_);
  447.       }
  448.       
  449.       private function deactivateHandler(param1:Event) : void
  450.       {
  451.       }
  452.       
  453.       private function setFocusToBottom() : void
  454.       {
  455.          setFocusToNextIndex(focusableObjects.length,true);
  456.       }
  457.       
  458.       private function tabIndexChangeHandler(param1:Event) : void
  459.       {
  460.          calculateCandidates = true;
  461.       }
  462.       
  463.       private function sortFocusableObjects() : void
  464.       {
  465.          var _loc3_:InteractiveObject = null;
  466.          focusableCandidates = [];
  467.          var _loc1_:int = int(focusableObjects.length);
  468.          var _loc2_:int = 0;
  469.          while(_loc2_ < _loc1_)
  470.          {
  471.             _loc3_ = focusableObjects[_loc2_];
  472.             if(_loc3_.tabIndex && !isNaN(Number(_loc3_.tabIndex)) && _loc3_.tabIndex > 0)
  473.             {
  474.                sortFocusableObjectsTabIndex();
  475.                return;
  476.             }
  477.             focusableCandidates.push(_loc3_);
  478.             _loc2_++;
  479.          }
  480.          focusableCandidates.sort(sortByDepth);
  481.       }
  482.       
  483.       private function keyFocusChangeHandler(param1:FocusEvent) : void
  484.       {
  485.          var _loc2_:ISystemManager = mx_internal::form.systemManager;
  486.          if(_loc2_.isDisplayObjectInABridgedApplication(DisplayObject(param1.target)))
  487.          {
  488.             return;
  489.          }
  490.          showFocusIndicator = true;
  491.          focusChanged = false;
  492.          if(param1.keyCode == Keyboard.TAB && !param1.isDefaultPrevented())
  493.          {
  494.             if(browserFocusComponent)
  495.             {
  496.                if(browserFocusComponent.tabIndex == LARGE_TAB_INDEX)
  497.                {
  498.                   browserFocusComponent.tabIndex = -1;
  499.                }
  500.                browserFocusComponent = null;
  501.                if(SystemManager(mx_internal::form.systemManager).useSWFBridge())
  502.                {
  503.                   moveFocusToParent(param1.shiftKey);
  504.                   if(focusChanged)
  505.                   {
  506.                      param1.preventDefault();
  507.                   }
  508.                }
  509.                return;
  510.             }
  511.             setFocusToNextObject(param1);
  512.             if(focusChanged)
  513.             {
  514.                param1.preventDefault();
  515.             }
  516.          }
  517.       }
  518.       
  519.       private function getNextFocusManagerComponent2(param1:Boolean = false, param2:DisplayObject = null, param3:int = -2) : FocusInfo
  520.       {
  521.          var _loc10_:DisplayObject = null;
  522.          var _loc11_:String = null;
  523.          var _loc12_:IFocusManagerGroup = null;
  524.          if(focusableObjects.length == 0)
  525.          {
  526.             return null;
  527.          }
  528.          if(calculateCandidates)
  529.          {
  530.             sortFocusableObjects();
  531.             calculateCandidates = false;
  532.          }
  533.          var _loc4_:int = param3;
  534.          if(param3 == FROM_INDEX_UNSPECIFIED)
  535.          {
  536.             _loc10_ = param2;
  537.             if(!_loc10_)
  538.             {
  539.                _loc10_ = mx_internal::form.systemManager.stage.focus;
  540.             }
  541.             _loc10_ = DisplayObject(findFocusManagerComponent2(InteractiveObject(_loc10_)));
  542.             _loc11_ = "";
  543.             if(_loc10_ is IFocusManagerGroup)
  544.             {
  545.                _loc12_ = IFocusManagerGroup(_loc10_);
  546.                _loc11_ = _loc12_.groupName;
  547.             }
  548.             _loc4_ = getIndexOfFocusedObject(_loc10_);
  549.          }
  550.          var _loc5_:Boolean = false;
  551.          var _loc6_:int = _loc4_;
  552.          if(_loc4_ == -1)
  553.          {
  554.             if(param1)
  555.             {
  556.                _loc4_ = int(focusableCandidates.length);
  557.             }
  558.             _loc5_ = true;
  559.          }
  560.          var _loc7_:int = getIndexOfNextObject(_loc4_,param1,_loc5_,_loc11_);
  561.          var _loc8_:Boolean = false;
  562.          if(param1)
  563.          {
  564.             if(_loc7_ >= _loc4_)
  565.             {
  566.                _loc8_ = true;
  567.             }
  568.          }
  569.          else if(_loc7_ <= _loc4_)
  570.          {
  571.             _loc8_ = true;
  572.          }
  573.          var _loc9_:FocusInfo = new FocusInfo();
  574.          _loc9_.displayObject = findFocusManagerComponent2(focusableCandidates[_loc7_]);
  575.          _loc9_.wrapped = _loc8_;
  576.          return _loc9_;
  577.       }
  578.       
  579.       private function getIndexOfFocusedObject(param1:DisplayObject) : int
  580.       {
  581.          var _loc4_:IUIComponent = null;
  582.          if(!param1)
  583.          {
  584.             return -1;
  585.          }
  586.          var _loc2_:int = int(focusableCandidates.length);
  587.          var _loc3_:int = 0;
  588.          _loc3_ = 0;
  589.          while(_loc3_ < _loc2_)
  590.          {
  591.             if(focusableCandidates[_loc3_] == param1)
  592.             {
  593.                return _loc3_;
  594.             }
  595.             _loc3_++;
  596.          }
  597.          _loc3_ = 0;
  598.          while(_loc3_ < _loc2_)
  599.          {
  600.             _loc4_ = focusableCandidates[_loc3_] as IUIComponent;
  601.             if((Boolean(_loc4_)) && Boolean(_loc4_.owns(param1)))
  602.             {
  603.                return _loc3_;
  604.             }
  605.             _loc3_++;
  606.          }
  607.          return -1;
  608.       }
  609.       
  610.       private function focusRequestActivateHandler(param1:Event) : void
  611.       {
  612.          skipBridge = IEventDispatcher(param1.target);
  613.          activate();
  614.          skipBridge = null;
  615.       }
  616.       
  617.       private function removeFromParentBridge(param1:Event) : void
  618.       {
  619.          var _loc3_:IEventDispatcher = null;
  620.          var _loc2_:ISystemManager = mx_internal::form.systemManager;
  621.          if(_loc2_.useSWFBridge())
  622.          {
  623.             _loc2_.removeEventListener(SWFBridgeEvent.BRIDGE_APPLICATION_UNLOADING,removeFromParentBridge);
  624.             _loc3_ = swfBridgeGroup.parentBridge;
  625.             if(_loc3_)
  626.             {
  627.                _loc3_.removeEventListener(SWFBridgeRequest.MOVE_FOCUS_REQUEST,focusRequestMoveHandler);
  628.                _loc3_.removeEventListener(SWFBridgeRequest.SET_SHOW_FOCUS_INDICATOR_REQUEST,setShowFocusIndicatorRequestHandler);
  629.             }
  630.             if(Boolean(_loc3_) && !(mx_internal::form.systemManager is SystemManagerProxy))
  631.             {
  632.                _loc3_.removeEventListener(SWFBridgeRequest.ACTIVATE_FOCUS_REQUEST,focusRequestActivateHandler);
  633.                _loc3_.removeEventListener(SWFBridgeRequest.DEACTIVATE_FOCUS_REQUEST,focusRequestDeactivateHandler);
  634.                _loc3_.removeEventListener(SWFBridgeEvent.BRIDGE_FOCUS_MANAGER_ACTIVATE,bridgeEventActivateHandler);
  635.             }
  636.          }
  637.       }
  638.       
  639.       private function getParentBridge() : IEventDispatcher
  640.       {
  641.          if(swfBridgeGroup)
  642.          {
  643.             return swfBridgeGroup.parentBridge;
  644.          }
  645.          return null;
  646.       }
  647.       
  648.       private function setFocusToComponent(param1:Object, param2:Boolean) : void
  649.       {
  650.          var _loc3_:SWFBridgeRequest = null;
  651.          var _loc4_:IEventDispatcher = null;
  652.          focusChanged = false;
  653.          if(param1)
  654.          {
  655.             if(param1 is ISWFLoader && Boolean(ISWFLoader(param1).swfBridge))
  656.             {
  657.                _loc3_ = new SWFBridgeRequest(SWFBridgeRequest.MOVE_FOCUS_REQUEST,false,true,null,param2 ? FocusRequestDirection.BOTTOM : FocusRequestDirection.TOP);
  658.                _loc4_ = ISWFLoader(param1).swfBridge;
  659.                if(_loc4_)
  660.                {
  661.                   _loc4_.dispatchEvent(_loc3_);
  662.                   focusChanged = _loc3_.data;
  663.                }
  664.             }
  665.             else if(param1 is IFocusManagerComplexComponent)
  666.             {
  667.                IFocusManagerComplexComponent(param1).assignFocus(param2 ? "bottom" : "top");
  668.                focusChanged = true;
  669.             }
  670.             else if(param1 is IFocusManagerComponent)
  671.             {
  672.                setFocus(IFocusManagerComponent(param1));
  673.                focusChanged = true;
  674.             }
  675.          }
  676.       }
  677.       
  678.       private function focusRequestMoveHandler(param1:Event) : void
  679.       {
  680.          var _loc3_:DisplayObject = null;
  681.          if(param1 is SWFBridgeRequest)
  682.          {
  683.             return;
  684.          }
  685.          focusSetLocally = false;
  686.          var _loc2_:SWFBridgeRequest = SWFBridgeRequest.marshal(param1);
  687.          if(_loc2_.data == FocusRequestDirection.TOP || _loc2_.data == FocusRequestDirection.BOTTOM)
  688.          {
  689.             if(focusableObjects.length == 0)
  690.             {
  691.                moveFocusToParent(_loc2_.data == FocusRequestDirection.TOP ? false : true);
  692.                param1["data"] = focusChanged;
  693.                return;
  694.             }
  695.             if(_loc2_.data == FocusRequestDirection.TOP)
  696.             {
  697.                setFocusToTop();
  698.             }
  699.             else
  700.             {
  701.                setFocusToBottom();
  702.             }
  703.             param1["data"] = focusChanged;
  704.          }
  705.          else
  706.          {
  707.             _loc3_ = DisplayObject(_form.systemManager.swfBridgeGroup.getChildBridgeProvider(IEventDispatcher(param1.target)));
  708.             moveFocus(_loc2_.data as String,_loc3_);
  709.             param1["data"] = focusChanged;
  710.          }
  711.          if(focusSetLocally)
  712.          {
  713.             dispatchActivatedFocusManagerEvent(null);
  714.             lastActiveFocusManager = this;
  715.          }
  716.       }
  717.       
  718.       public function get nextTabIndex() : int
  719.       {
  720.          return getMaxTabIndex() + 1;
  721.       }
  722.       
  723.       private function dispatchActivatedFocusManagerEvent(param1:IEventDispatcher = null) : void
  724.       {
  725.          if(lastActiveFocusManager == this)
  726.          {
  727.             return;
  728.          }
  729.          var _loc2_:SWFBridgeEvent = new SWFBridgeEvent(SWFBridgeEvent.BRIDGE_FOCUS_MANAGER_ACTIVATE);
  730.          dispatchEventFromSWFBridges(_loc2_,param1);
  731.       }
  732.       
  733.       private function focusRequestDeactivateHandler(param1:Event) : void
  734.       {
  735.          skipBridge = IEventDispatcher(param1.target);
  736.          deactivate();
  737.          skipBridge = null;
  738.       }
  739.       
  740.       public function get focusPane() : Sprite
  741.       {
  742.          return _focusPane;
  743.       }
  744.       
  745.       private function keyDownHandler(param1:KeyboardEvent) : void
  746.       {
  747.          var _loc3_:DisplayObject = null;
  748.          var _loc4_:String = null;
  749.          var _loc5_:int = 0;
  750.          var _loc6_:int = 0;
  751.          var _loc7_:IFocusManagerGroup = null;
  752.          var _loc2_:ISystemManager = mx_internal::form.systemManager;
  753.          if(_loc2_.isDisplayObjectInABridgedApplication(DisplayObject(param1.target)))
  754.          {
  755.             return;
  756.          }
  757.          if(_loc2_ is SystemManager)
  758.          {
  759.             SystemManager(_loc2_).mx_internal::idleCounter = 0;
  760.          }
  761.          if(param1.keyCode == Keyboard.TAB)
  762.          {
  763.             lastAction = "KEY";
  764.             if(calculateCandidates)
  765.             {
  766.                sortFocusableObjects();
  767.                calculateCandidates = false;
  768.             }
  769.          }
  770.          if(browserMode)
  771.          {
  772.             if(param1.keyCode == Keyboard.TAB && focusableCandidates.length > 0)
  773.             {
  774.                _loc3_ = fauxFocus;
  775.                if(!_loc3_)
  776.                {
  777.                   _loc3_ = mx_internal::form.systemManager.stage.focus;
  778.                }
  779.                _loc3_ = DisplayObject(findFocusManagerComponent2(InteractiveObject(_loc3_)));
  780.                _loc4_ = "";
  781.                if(_loc3_ is IFocusManagerGroup)
  782.                {
  783.                   _loc7_ = IFocusManagerGroup(_loc3_);
  784.                   _loc4_ = _loc7_.groupName;
  785.                }
  786.                _loc5_ = getIndexOfFocusedObject(_loc3_);
  787.                _loc6_ = getIndexOfNextObject(_loc5_,param1.shiftKey,false,_loc4_);
  788.                if(param1.shiftKey)
  789.                {
  790.                   if(_loc6_ >= _loc5_)
  791.                   {
  792.                      browserFocusComponent = getBrowserFocusComponent(param1.shiftKey);
  793.                      if(browserFocusComponent.tabIndex == -1)
  794.                      {
  795.                         browserFocusComponent.tabIndex = 0;
  796.                      }
  797.                   }
  798.                }
  799.                else if(_loc6_ <= _loc5_)
  800.                {
  801.                   browserFocusComponent = getBrowserFocusComponent(param1.shiftKey);
  802.                   if(browserFocusComponent.tabIndex == -1)
  803.                   {
  804.                      browserFocusComponent.tabIndex = LARGE_TAB_INDEX;
  805.                   }
  806.                }
  807.             }
  808.          }
  809.          if(defaultButtonEnabled && param1.keyCode == Keyboard.ENTER && defaultButton && Boolean(defButton.enabled))
  810.          {
  811.             defButton.callLater(mx_internal::sendDefaultButtonEvent);
  812.          }
  813.       }
  814.       
  815.       private function mouseDownHandler(param1:MouseEvent) : void
  816.       {
  817.          if(param1.isDefaultPrevented())
  818.          {
  819.             return;
  820.          }
  821.          var _loc2_:ISystemManager = mx_internal::form.systemManager;
  822.          var _loc3_:DisplayObject = getTopLevelFocusTarget(InteractiveObject(param1.target));
  823.          if(!_loc3_)
  824.          {
  825.             return;
  826.          }
  827.          showFocusIndicator = false;
  828.          if((_loc3_ != _lastFocus || lastAction == "ACTIVATE") && !(_loc3_ is TextField))
  829.          {
  830.             setFocus(IFocusManagerComponent(_loc3_));
  831.          }
  832.          else if(_lastFocus)
  833.          {
  834.             if(!_lastFocus && _loc3_ is IEventDispatcher && SystemManager(mx_internal::form.systemManager).useSWFBridge())
  835.             {
  836.                IEventDispatcher(_loc3_).dispatchEvent(new FocusEvent(FocusEvent.FOCUS_IN));
  837.             }
  838.          }
  839.          lastAction = "MOUSEDOWN";
  840.          dispatchActivatedFocusManagerEvent(null);
  841.          lastActiveFocusManager = this;
  842.       }
  843.       
  844.       private function focusInHandler(param1:FocusEvent) : void
  845.       {
  846.          var _loc4_:IButton = null;
  847.          var _loc2_:InteractiveObject = InteractiveObject(param1.target);
  848.          var _loc3_:ISystemManager = mx_internal::form.systemManager;
  849.          if(_loc3_.isDisplayObjectInABridgedApplication(DisplayObject(param1.target)))
  850.          {
  851.             return;
  852.          }
  853.          if(isParent(DisplayObjectContainer(mx_internal::form),_loc2_))
  854.          {
  855.             _lastFocus = findFocusManagerComponent(InteractiveObject(_loc2_));
  856.             if(_lastFocus is IButton)
  857.             {
  858.                _loc4_ = _lastFocus as IButton;
  859.                if(defButton)
  860.                {
  861.                   defButton.emphasized = false;
  862.                   defButton = _loc4_;
  863.                   _loc4_.emphasized = true;
  864.                }
  865.             }
  866.             else if(Boolean(defButton) && defButton != _defaultButton)
  867.             {
  868.                defButton.emphasized = false;
  869.                defButton = _defaultButton;
  870.                _defaultButton.emphasized = true;
  871.             }
  872.          }
  873.       }
  874.       
  875.       public function toString() : String
  876.       {
  877.          return Object(mx_internal::form).toString() + ".focusManager";
  878.       }
  879.       
  880.       public function deactivate() : void
  881.       {
  882.          var _loc1_:ISystemManager = mx_internal::form.systemManager;
  883.          if(_loc1_)
  884.          {
  885.             if(_loc1_.isTopLevelRoot())
  886.             {
  887.                _loc1_.stage.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE,mouseFocusChangeHandler);
  888.                _loc1_.stage.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE,keyFocusChangeHandler);
  889.                _loc1_.stage.removeEventListener(Event.ACTIVATE,activateHandler);
  890.                _loc1_.stage.removeEventListener(Event.DEACTIVATE,deactivateHandler);
  891.             }
  892.             else
  893.             {
  894.                _loc1_.removeEventListener(FocusEvent.MOUSE_FOCUS_CHANGE,mouseFocusChangeHandler);
  895.                _loc1_.removeEventListener(FocusEvent.KEY_FOCUS_CHANGE,keyFocusChangeHandler);
  896.                _loc1_.removeEventListener(Event.ACTIVATE,activateHandler);
  897.                _loc1_.removeEventListener(Event.DEACTIVATE,deactivateHandler);
  898.             }
  899.          }
  900.          mx_internal::form.removeEventListener(FocusEvent.FOCUS_IN,focusInHandler,true);
  901.          mx_internal::form.removeEventListener(FocusEvent.FOCUS_OUT,focusOutHandler,true);
  902.          mx_internal::form.removeEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
  903.          mx_internal::form.removeEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler,true);
  904.          activated = false;
  905.          dispatchEventFromSWFBridges(new SWFBridgeRequest(SWFBridgeRequest.DEACTIVATE_FOCUS_REQUEST),skipBridge);
  906.       }
  907.       
  908.       private function findFocusManagerComponent2(param1:InteractiveObject) : DisplayObject
  909.       {
  910.          var o:InteractiveObject = param1;
  911.          try
  912.          {
  913.             while(o)
  914.             {
  915.                if(o is IFocusManagerComponent && Boolean(IFocusManagerComponent(o).focusEnabled) || o is ISWFLoader)
  916.                {
  917.                   return o;
  918.                }
  919.                o = o.parent;
  920.             }
  921.          }
  922.          catch(error:SecurityError)
  923.          {
  924.          }
  925.          return null;
  926.       }
  927.       
  928.       private function getIndexOfNextObject(param1:int, param2:Boolean, param3:Boolean, param4:String) : int
  929.       {
  930.          var _loc7_:DisplayObject = null;
  931.          var _loc8_:IFocusManagerGroup = null;
  932.          var _loc9_:int = 0;
  933.          var _loc10_:DisplayObject = null;
  934.          var _loc11_:IFocusManagerGroup = null;
  935.          var _loc5_:int = int(focusableCandidates.length);
  936.          var _loc6_:int = param1;
  937.          while(true)
  938.          {
  939.             if(param2)
  940.             {
  941.                param1--;
  942.             }
  943.             else
  944.             {
  945.                param1++;
  946.             }
  947.             if(param3)
  948.             {
  949.                if(param2 && param1 < 0)
  950.                {
  951.                   break;
  952.                }
  953.                if(!param2 && param1 == _loc5_)
  954.                {
  955.                   break;
  956.                }
  957.             }
  958.             else
  959.             {
  960.                param1 = (param1 + _loc5_) % _loc5_;
  961.                if(_loc6_ == param1)
  962.                {
  963.                   break;
  964.                }
  965.             }
  966.             if(isValidFocusCandidate(focusableCandidates[param1],param4))
  967.             {
  968.                _loc7_ = DisplayObject(findFocusManagerComponent2(focusableCandidates[param1]));
  969.                if(_loc7_ is IFocusManagerGroup)
  970.                {
  971.                   _loc8_ = IFocusManagerGroup(_loc7_);
  972.                   _loc9_ = 0;
  973.                   while(_loc9_ < focusableCandidates.length)
  974.                   {
  975.                      _loc10_ = focusableCandidates[_loc9_];
  976.                      if(_loc10_ is IFocusManagerGroup)
  977.                      {
  978.                         _loc11_ = IFocusManagerGroup(_loc10_);
  979.                         if(_loc11_.groupName == _loc8_.groupName && _loc11_.selected)
  980.                         {
  981.                            if(InteractiveObject(_loc10_).tabIndex != InteractiveObject(_loc7_).tabIndex && !_loc8_.selected)
  982.                            {
  983.                               return getIndexOfNextObject(param1,param2,param3,param4);
  984.                            }
  985.                            param1 = _loc9_;
  986.                            break;
  987.                         }
  988.                      }
  989.                      _loc9_++;
  990.                   }
  991.                }
  992.                return param1;
  993.             }
  994.          }
  995.          return param1;
  996.       }
  997.       
  998.       public function moveFocus(param1:String, param2:DisplayObject = null) : void
  999.       {
  1000.          if(param1 == FocusRequestDirection.TOP)
  1001.          {
  1002.             setFocusToTop();
  1003.             return;
  1004.          }
  1005.          if(param1 == FocusRequestDirection.BOTTOM)
  1006.          {
  1007.             setFocusToBottom();
  1008.             return;
  1009.          }
  1010.          var _loc3_:KeyboardEvent = new KeyboardEvent(KeyboardEvent.KEY_DOWN);
  1011.          _loc3_.keyCode = Keyboard.TAB;
  1012.          _loc3_.shiftKey = param1 == FocusRequestDirection.FORWARD ? false : true;
  1013.          fauxFocus = param2;
  1014.          keyDownHandler(_loc3_);
  1015.          var _loc4_:FocusEvent = new FocusEvent(FocusEvent.KEY_FOCUS_CHANGE);
  1016.          _loc4_.keyCode = Keyboard.TAB;
  1017.          _loc4_.shiftKey = param1 == FocusRequestDirection.FORWARD ? false : true;
  1018.          keyFocusChangeHandler(_loc4_);
  1019.          fauxFocus = null;
  1020.       }
  1021.       
  1022.       private function getMaxTabIndex() : int
  1023.       {
  1024.          var _loc4_:Number = NaN;
  1025.          var _loc1_:Number = 0;
  1026.          var _loc2_:int = int(focusableObjects.length);
  1027.          var _loc3_:int = 0;
  1028.          while(_loc3_ < _loc2_)
  1029.          {
  1030.             _loc4_ = Number(focusableObjects[_loc3_].tabIndex);
  1031.             if(!isNaN(_loc4_))
  1032.             {
  1033.                _loc1_ = Math.max(_loc1_,_loc4_);
  1034.             }
  1035.             _loc3_++;
  1036.          }
  1037.          return _loc1_;
  1038.       }
  1039.       
  1040.       private function isParent(param1:DisplayObjectContainer, param2:DisplayObject) : Boolean
  1041.       {
  1042.          if(param1 is IRawChildrenContainer)
  1043.          {
  1044.             return IRawChildrenContainer(param1).rawChildren.contains(param2);
  1045.          }
  1046.          return param1.contains(param2);
  1047.       }
  1048.       
  1049.       private function showHandler(param1:Event) : void
  1050.       {
  1051.          mx_internal::form.systemManager.activate(mx_internal::form);
  1052.       }
  1053.       
  1054.       mx_internal function set form(param1:IFocusManagerContainer) : void
  1055.       {
  1056.          _form = param1;
  1057.       }
  1058.       
  1059.       public function setFocus(param1:IFocusManagerComponent) : void
  1060.       {
  1061.          param1.setFocus();
  1062.          focusSetLocally = true;
  1063.       }
  1064.       
  1065.       public function findFocusManagerComponent(param1:InteractiveObject) : IFocusManagerComponent
  1066.       {
  1067.          return findFocusManagerComponent2(param1) as IFocusManagerComponent;
  1068.       }
  1069.       
  1070.       public function removeSWFBridge(param1:IEventDispatcher) : void
  1071.       {
  1072.          var _loc4_:int = 0;
  1073.          var _loc2_:ISystemManager = _form.systemManager;
  1074.          var _loc3_:DisplayObject = DisplayObject(swfBridgeGroup.getChildBridgeProvider(param1));
  1075.          if(_loc3_)
  1076.          {
  1077.             _loc4_ = int(focusableObjects.indexOf(_loc3_));
  1078.             if(_loc4_ != -1)
  1079.             {
  1080.                focusableObjects.splice(_loc4_,1);
  1081.                calculateCandidates = true;
  1082.             }
  1083.             param1.removeEventListener(SWFBridgeRequest.MOVE_FOCUS_REQUEST,focusRequestMoveHandler);
  1084.             param1.removeEventListener(SWFBridgeRequest.SET_SHOW_FOCUS_INDICATOR_REQUEST,setShowFocusIndicatorRequestHandler);
  1085.             param1.removeEventListener(SWFBridgeEvent.BRIDGE_FOCUS_MANAGER_ACTIVATE,bridgeEventActivateHandler);
  1086.             swfBridgeGroup.removeChildBridge(param1);
  1087.             return;
  1088.          }
  1089.          throw new Error();
  1090.       }
  1091.       
  1092.       private function sortFocusableObjectsTabIndex() : void
  1093.       {
  1094.          var _loc3_:IFocusManagerComponent = null;
  1095.          focusableCandidates = [];
  1096.          var _loc1_:int = int(focusableObjects.length);
  1097.          var _loc2_:int = 0;
  1098.          while(_loc2_ < _loc1_)
  1099.          {
  1100.             _loc3_ = focusableObjects[_loc2_] as IFocusManagerComponent;
  1101.             if(_loc3_ && _loc3_.tabIndex && !isNaN(Number(_loc3_.tabIndex)) || focusableObjects[_loc2_] is ISWFLoader)
  1102.             {
  1103.                focusableCandidates.push(focusableObjects[_loc2_]);
  1104.             }
  1105.             _loc2_++;
  1106.          }
  1107.          focusableCandidates.sort(sortByTabIndex);
  1108.       }
  1109.       
  1110.       public function set defaultButton(param1:IButton) : void
  1111.       {
  1112.          var _loc2_:IButton = !!param1 ? IButton(param1) : null;
  1113.          if(_loc2_ != _defaultButton)
  1114.          {
  1115.             if(_defaultButton)
  1116.             {
  1117.                _defaultButton.emphasized = false;
  1118.             }
  1119.             if(defButton)
  1120.             {
  1121.                defButton.emphasized = false;
  1122.             }
  1123.             _defaultButton = _loc2_;
  1124.             defButton = _loc2_;
  1125.             if(_loc2_)
  1126.             {
  1127.                _loc2_.emphasized = true;
  1128.             }
  1129.          }
  1130.       }
  1131.       
  1132.       private function setFocusToNextObject(param1:FocusEvent) : void
  1133.       {
  1134.          focusChanged = false;
  1135.          if(focusableObjects.length == 0)
  1136.          {
  1137.             return;
  1138.          }
  1139.          var _loc2_:FocusInfo = getNextFocusManagerComponent2(param1.shiftKey,fauxFocus);
  1140.          if(!popup && _loc2_.wrapped)
  1141.          {
  1142.             if(getParentBridge())
  1143.             {
  1144.                moveFocusToParent(param1.shiftKey);
  1145.                return;
  1146.             }
  1147.          }
  1148.          setFocusToComponent(_loc2_.displayObject,param1.shiftKey);
  1149.       }
  1150.       
  1151.       private function getTopLevelFocusTarget(param1:InteractiveObject) : InteractiveObject
  1152.       {
  1153.          while(param1 != InteractiveObject(mx_internal::form))
  1154.          {
  1155.             if(param1 is IFocusManagerComponent && Boolean(IFocusManagerComponent(param1).focusEnabled) && Boolean(IFocusManagerComponent(param1).mouseFocusEnabled) && (param1 is IUIComponent ? IUIComponent(param1).enabled : true))
  1156.             {
  1157.                return param1;
  1158.             }
  1159.             if(param1.parent is ISWFLoader)
  1160.             {
  1161.                if(ISWFLoader(param1.parent).swfBridge)
  1162.                {
  1163.                   return null;
  1164.                }
  1165.             }
  1166.             param1 = param1.parent;
  1167.             if(param1 == null)
  1168.             {
  1169.                break;
  1170.             }
  1171.          }
  1172.          return null;
  1173.       }
  1174.       
  1175.       private function addedToStageHandler(param1:Event) : void
  1176.       {
  1177.          _form.removeEventListener(Event.ADDED_TO_STAGE,addedToStageHandler);
  1178.          if(focusableObjects.length == 0)
  1179.          {
  1180.             addFocusables(DisplayObject(_form));
  1181.             calculateCandidates = true;
  1182.          }
  1183.       }
  1184.       
  1185.       private function hideHandler(param1:Event) : void
  1186.       {
  1187.          mx_internal::form.systemManager.deactivate(mx_internal::form);
  1188.       }
  1189.       
  1190.       private function isEnabledAndVisible(param1:DisplayObject) : Boolean
  1191.       {
  1192.          var _loc2_:DisplayObjectContainer = DisplayObject(mx_internal::form).parent;
  1193.          while(param1 != _loc2_)
  1194.          {
  1195.             if(param1 is IUIComponent)
  1196.             {
  1197.                if(!IUIComponent(param1).enabled)
  1198.                {
  1199.                   return false;
  1200.                }
  1201.             }
  1202.             if(!param1.visible)
  1203.             {
  1204.                return false;
  1205.             }
  1206.             param1 = param1.parent;
  1207.          }
  1208.          return true;
  1209.       }
  1210.       
  1211.       public function hideFocus() : void
  1212.       {
  1213.          if(showFocusIndicator)
  1214.          {
  1215.             showFocusIndicator = false;
  1216.             if(_lastFocus)
  1217.             {
  1218.                _lastFocus.drawFocus(false);
  1219.             }
  1220.          }
  1221.       }
  1222.       
  1223.       private function getBrowserFocusComponent(param1:Boolean) : InteractiveObject
  1224.       {
  1225.          var _loc3_:int = 0;
  1226.          var _loc2_:InteractiveObject = mx_internal::form.systemManager.stage.focus;
  1227.          if(!_loc2_)
  1228.          {
  1229.             _loc3_ = param1 ? 0 : int(focusableCandidates.length - 1);
  1230.             _loc2_ = focusableCandidates[_loc3_];
  1231.          }
  1232.          return _loc2_;
  1233.       }
  1234.       
  1235.       public function get showFocusIndicator() : Boolean
  1236.       {
  1237.          return _showFocusIndicator;
  1238.       }
  1239.       
  1240.       private function moveFocusToParent(param1:Boolean) : Boolean
  1241.       {
  1242.          var _loc2_:SWFBridgeRequest = new SWFBridgeRequest(SWFBridgeRequest.MOVE_FOCUS_REQUEST,false,true,null,param1 ? FocusRequestDirection.BACKWARD : FocusRequestDirection.FORWARD);
  1243.          var _loc3_:IEventDispatcher = _form.systemManager.swfBridgeGroup.parentBridge;
  1244.          _loc3_.dispatchEvent(_loc2_);
  1245.          focusChanged = _loc2_.data;
  1246.          return focusChanged;
  1247.       }
  1248.       
  1249.       public function set focusPane(param1:Sprite) : void
  1250.       {
  1251.          _focusPane = param1;
  1252.       }
  1253.       
  1254.       mx_internal function get form() : IFocusManagerContainer
  1255.       {
  1256.          return _form;
  1257.       }
  1258.       
  1259.       private function removedHandler(param1:Event) : void
  1260.       {
  1261.          var _loc2_:int = 0;
  1262.          var _loc3_:DisplayObject = DisplayObject(param1.target);
  1263.          if(_loc3_ is IFocusManagerComponent)
  1264.          {
  1265.             _loc2_ = 0;
  1266.             while(_loc2_ < focusableObjects.length)
  1267.             {
  1268.                if(_loc3_ == focusableObjects[_loc2_])
  1269.                {
  1270.                   if(_loc3_ == _lastFocus)
  1271.                   {
  1272.                      _lastFocus.drawFocus(false);
  1273.                      _lastFocus = null;
  1274.                   }
  1275.                   _loc3_.removeEventListener("tabEnabledChange",tabEnabledChangeHandler);
  1276.                   _loc3_.removeEventListener("tabIndexChange",tabIndexChangeHandler);
  1277.                   focusableObjects.splice(_loc2_,1);
  1278.                   calculateCandidates = true;
  1279.                   break;
  1280.                }
  1281.                _loc2_++;
  1282.             }
  1283.          }
  1284.          removeFocusables(_loc3_,false);
  1285.       }
  1286.       
  1287.       private function dispatchEventFromSWFBridges(param1:Event, param2:IEventDispatcher = null) : void
  1288.       {
  1289.          var _loc3_:Event = null;
  1290.          var _loc7_:IEventDispatcher = null;
  1291.          var _loc4_:ISystemManager = mx_internal::form.systemManager;
  1292.          if(!popup)
  1293.          {
  1294.             _loc7_ = swfBridgeGroup.parentBridge;
  1295.             if((Boolean(_loc7_)) && _loc7_ != param2)
  1296.             {
  1297.                _loc3_ = param1.clone();
  1298.                if(_loc3_ is SWFBridgeRequest)
  1299.                {
  1300.                   SWFBridgeRequest(_loc3_).requestor = _loc7_;
  1301.                }
  1302.                _loc7_.dispatchEvent(_loc3_);
  1303.             }
  1304.          }
  1305.          var _loc5_:Array = swfBridgeGroup.getChildBridges();
  1306.          var _loc6_:int = 0;
  1307.          while(_loc6_ < _loc5_.length)
  1308.          {
  1309.             if(_loc5_[_loc6_] != param2)
  1310.             {
  1311.                _loc3_ = param1.clone();
  1312.                if(_loc3_ is SWFBridgeRequest)
  1313.                {
  1314.                   SWFBridgeRequest(_loc3_).requestor = IEventDispatcher(_loc5_[_loc6_]);
  1315.                }
  1316.                IEventDispatcher(_loc5_[_loc6_]).dispatchEvent(_loc3_);
  1317.             }
  1318.             _loc6_++;
  1319.          }
  1320.       }
  1321.       
  1322.       public function get defaultButton() : IButton
  1323.       {
  1324.          return _defaultButton;
  1325.       }
  1326.       
  1327.       private function activateHandler(param1:Event) : void
  1328.       {
  1329.          if(Boolean(_lastFocus) && !browserMode)
  1330.          {
  1331.             _lastFocus.setFocus();
  1332.          }
  1333.          lastAction = "ACTIVATE";
  1334.       }
  1335.       
  1336.       public function showFocus() : void
  1337.       {
  1338.          if(!showFocusIndicator)
  1339.          {
  1340.             showFocusIndicator = true;
  1341.             if(_lastFocus)
  1342.             {
  1343.                _lastFocus.drawFocus(true);
  1344.             }
  1345.          }
  1346.       }
  1347.       
  1348.       public function getNextFocusManagerComponent(param1:Boolean = false) : IFocusManagerComponent
  1349.       {
  1350.          return getNextFocusManagerComponent2(false,fauxFocus) as IFocusManagerComponent;
  1351.       }
  1352.       
  1353.       private function setShowFocusIndicatorRequestHandler(param1:Event) : void
  1354.       {
  1355.          if(param1 is SWFBridgeRequest)
  1356.          {
  1357.             return;
  1358.          }
  1359.          var _loc2_:SWFBridgeRequest = SWFBridgeRequest.marshal(param1);
  1360.          _showFocusIndicator = _loc2_.data;
  1361.          dispatchSetShowFocusIndicatorRequest(_showFocusIndicator,IEventDispatcher(param1.target));
  1362.       }
  1363.       
  1364.       private function setFocusToTop() : void
  1365.       {
  1366.          setFocusToNextIndex(-1,false);
  1367.       }
  1368.       
  1369.       private function isTabVisible(param1:DisplayObject) : Boolean
  1370.       {
  1371.          var _loc2_:DisplayObject = DisplayObject(mx_internal::form.systemManager);
  1372.          if(!_loc2_)
  1373.          {
  1374.             return false;
  1375.          }
  1376.          var _loc3_:DisplayObjectContainer = param1.parent;
  1377.          while(Boolean(_loc3_) && _loc3_ != _loc2_)
  1378.          {
  1379.             if(!_loc3_.tabChildren)
  1380.             {
  1381.                return false;
  1382.             }
  1383.             _loc3_ = _loc3_.parent;
  1384.          }
  1385.          return true;
  1386.       }
  1387.       
  1388.       mx_internal function get lastFocus() : IFocusManagerComponent
  1389.       {
  1390.          return _lastFocus;
  1391.       }
  1392.       
  1393.       public function set defaultButtonEnabled(param1:Boolean) : void
  1394.       {
  1395.          _defaultButtonEnabled = param1;
  1396.       }
  1397.       
  1398.       public function get defaultButtonEnabled() : Boolean
  1399.       {
  1400.          return _defaultButtonEnabled;
  1401.       }
  1402.       
  1403.       public function set showFocusIndicator(param1:Boolean) : void
  1404.       {
  1405.          var _loc2_:* = _showFocusIndicator != param1;
  1406.          _showFocusIndicator = param1;
  1407.          if(_loc2_ && !popup && Boolean(mx_internal::form.systemManager.swfBridgeGroup))
  1408.          {
  1409.             dispatchSetShowFocusIndicatorRequest(param1,null);
  1410.          }
  1411.       }
  1412.       
  1413.       private function sortByTabIndex(param1:InteractiveObject, param2:InteractiveObject) : int
  1414.       {
  1415.          var _loc3_:int = param1.tabIndex;
  1416.          var _loc4_:int = param2.tabIndex;
  1417.          if(_loc3_ == -1)
  1418.          {
  1419.             _loc3_ = int.MAX_VALUE;
  1420.          }
  1421.          if(_loc4_ == -1)
  1422.          {
  1423.             _loc4_ = int.MAX_VALUE;
  1424.          }
  1425.          return _loc3_ > _loc4_ ? 1 : (_loc3_ < _loc4_ ? -1 : int(sortByDepth(DisplayObject(param1),DisplayObject(param2))));
  1426.       }
  1427.       
  1428.       public function activate() : void
  1429.       {
  1430.          if(activated)
  1431.          {
  1432.             return;
  1433.          }
  1434.          var _loc1_:ISystemManager = mx_internal::form.systemManager;
  1435.          if(_loc1_)
  1436.          {
  1437.             if(_loc1_.isTopLevelRoot())
  1438.             {
  1439.                _loc1_.stage.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE,mouseFocusChangeHandler,false,0,true);
  1440.                _loc1_.stage.addEventListener(FocusEvent.KEY_FOCUS_CHANGE,keyFocusChangeHandler,false,0,true);
  1441.                _loc1_.stage.addEventListener(Event.ACTIVATE,activateHandler,false,0,true);
  1442.                _loc1_.stage.addEventListener(Event.DEACTIVATE,deactivateHandler,false,0,true);
  1443.             }
  1444.             else
  1445.             {
  1446.                _loc1_.addEventListener(FocusEvent.MOUSE_FOCUS_CHANGE,mouseFocusChangeHandler,false,0,true);
  1447.                _loc1_.addEventListener(FocusEvent.KEY_FOCUS_CHANGE,keyFocusChangeHandler,false,0,true);
  1448.                _loc1_.addEventListener(Event.ACTIVATE,activateHandler,false,0,true);
  1449.                _loc1_.addEventListener(Event.DEACTIVATE,deactivateHandler,false,0,true);
  1450.             }
  1451.          }
  1452.          mx_internal::form.addEventListener(FocusEvent.FOCUS_IN,focusInHandler,true);
  1453.          mx_internal::form.addEventListener(FocusEvent.FOCUS_OUT,focusOutHandler,true);
  1454.          mx_internal::form.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
  1455.          mx_internal::form.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler,true);
  1456.          activated = true;
  1457.          if(_lastFocus)
  1458.          {
  1459.             setFocus(_lastFocus);
  1460.          }
  1461.          dispatchEventFromSWFBridges(new SWFBridgeRequest(SWFBridgeRequest.ACTIVATE_FOCUS_REQUEST),skipBridge);
  1462.       }
  1463.       
  1464.       private function setFocusToNextIndex(param1:int, param2:Boolean) : void
  1465.       {
  1466.          if(focusableObjects.length == 0)
  1467.          {
  1468.             return;
  1469.          }
  1470.          if(calculateCandidates)
  1471.          {
  1472.             sortFocusableObjects();
  1473.             calculateCandidates = false;
  1474.          }
  1475.          var _loc3_:FocusInfo = getNextFocusManagerComponent2(param2,null,param1);
  1476.          if(!popup && _loc3_.wrapped)
  1477.          {
  1478.             if(getParentBridge())
  1479.             {
  1480.                moveFocusToParent(param2);
  1481.                return;
  1482.             }
  1483.          }
  1484.          setFocusToComponent(_loc3_.displayObject,param2);
  1485.       }
  1486.    }
  1487. }
  1488.  
  1489. import flash.display.DisplayObject;
  1490.  
  1491. class FocusInfo
  1492. {
  1493.    public var displayObject:DisplayObject;
  1494.    
  1495.    public var wrapped:Boolean;
  1496.    
  1497.    public function FocusInfo()
  1498.    {
  1499.       super();
  1500.    }
  1501. }
  1502.